package com.zjj.day0425.regex;

/**
 * @author zhoujunjie
 * @desc TODO
 * @date 2025/4/25
 */
import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class ContactInfoExtractor {
    public static void main(String[] args) {
        String text = "你好，若有问题请及时电话联系0510-1231231或者05101112223，也可以发送邮件至123@qq.com。" +
                "若遇紧急问题，可拨打13911112222，或者18523234646。欢迎致电800-820-8820，8008208820。";

        String phoneRegex = "(?:\\d{3,4}-)?\\d{7,8}|1[3-9]\\d{9}|800(?:-?\\d{3}){2}";
        Pattern phonePattern = Pattern.compile(phoneRegex);
        Matcher phoneMatcher = phonePattern.matcher(text);

        System.out.println("提取到的电话号码：");
        while (phoneMatcher.find()) {
            System.out.println(phoneMatcher.group());
        }

        String emailRegex = "\\w+@\\w+\\.\\w+";
        Pattern emailPattern = Pattern.compile(emailRegex);
        Matcher emailMatcher = emailPattern.matcher(text);

        System.out.println("\n提取到的邮箱：");
        while (emailMatcher.find()) {
            System.out.println(emailMatcher.group());
        }
    }
}